import { gql, QueryResult, useLazyQuery, useQuery } from "@apollo/client";

import { ParamDataPayload, ParamDataQuery, Query } from "../api-server/types";

// 获取参数列表
export const useRemotePathList = () => {
  const document = gql`
    query paramsData($query: ParamDataQuery!) {
      paramsData(query: $query) {
        id
        flightId
        metric {
          name
        }
        dataSource
        processStatus
      }
    }
  `;

  const [load, { loading }] = useLazyQuery<Query>(document);
  const loadResult = async (query: ParamDataQuery): Promise<any> => {
    const query_d = {
      variables: {
        query,
      },
    };
    return await load(query_d);
  };

  return { loadResult, loading };
};
